﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Babelfish
{
    /// <summary>
    /// 
    /// </summary>
    public class NodeCollection : List<INode>
    {
        public delegate void CollectionUpdatedHandler(object sender, EventArgs args);
        public event CollectionUpdatedHandler CollectionUpdated;

        /// <summary>
        /// Initializes a new instance of the <see cref="NodeCollection"/> class.
        /// </summary>
        public NodeCollection()
        {
            //CollectionUpdated
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="NodeCollection"/> class.
        /// </summary>
        /// <param name="nodes">The nodes.</param>
        public NodeCollection(IEnumerable<INode> nodes)
            : base(nodes)
        {

        }

        /// <summary>
        /// Gets the <see cref="Babelfish.INode"/> with the specified node name.
        /// </summary>
        /// <value></value>
        public INode this[string nodeName]
        {
            get
            {
                return this.Where(node => node.Name == nodeName).FirstOrDefault() ?? new EmptyNode();
            }
        }
    }
}
